import { BaseController, CoolController } from "@cool-midway/core";
import { Get, Inject, Query, Post, Body } from "@midwayjs/core";
import { CarInfoService } from "../../service/car/info";
import { CarInfoEntity } from "../../entity/car/info";
import { Context } from "@midwayjs/koa";
import { AddCarDTO } from "../../dto/car";

@CoolController({
    api: ['list', 'delete'],
    entity: CarInfoEntity,
    service: CarInfoService,

})
export class ProviderAppTransportCarController extends BaseController {
    @Inject()
    carInfoService: CarInfoService;

    @Inject()
    ctx: Context;

    @Get('/byCurrentTeam', { summary: '获取当前团队下车辆' })
    async byCurrentTeam() {
        return this.ok(await this.carInfoService.listByCurrentTeam());
    }

    @Get('/my', { summary: '获取我绑定的车辆' })
    async myCar() {
        return this.ok(await this.carInfoService.getByProviderId(this.ctx.provider.id));
    }

    @Get('/listForCurrentUser', { summary: '按当前用户视角返回团队车辆与个人车辆' })
    async listForCurrentUser() {
        return this.ok(await this.carInfoService.listForCurrentUser());
    }

    @Post('/addMyCar', { summary: '服务人员新增车辆' })
    async addMyCar(@Body() dto: AddCarDTO) {
        return this.ok(await this.carInfoService.addMyCar(dto));
    }
}
